<?

$id_evt = $_GET["id_evt"];
$adresse = $_GET["adresse"];
$cp = $_GET["cp"];
$ville = $_GET["ville"];


?>

<!-- <div id="map_canvas2" style="width: 500px; height: 280px"></div>
  </div>
-->
<?
  echo "<div id='gmaps".$id_evt."' style='width: 500px; height: 280px'></div>\n";
  echo  "<a href='http://maps.google.fr/maps?f=q&hl=fr".
              "&geocode=&q=".$adresse.
              ",".$cp." ".$ville.
              "&sll=47.15984,2.988281&sspn=11.088496,28.564453&ie=UTF8&t=h&z=16&iwloc=addr&iwstate1=dir' ".
              "target='_blank' class='blanc'>Plan</a><br>";

echo"<script type='text/javascript'> \n";
echo"    function manageMap(){\n";
echo"       if( GBrowserIsCompatible()){\n";        
echo"          var mapId = 'gmaps'+$id_evt;";
echo"          var map = new GMap2(document.getElementById(mapId),{size:new GSize(600,280)});\n";
echo"          var mapTypeControl = new GMapTypeControl(true);\n";
echo"          var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));\n";
echo"          var geocoder = new GClientGeocoder();\n";
echo"          var address = '$adresse, $cp $ville';";
echo"          geocoder.getLatLng(\n";
echo"            address,\n";
echo"            function(point) {\n";
echo"              if (!point) {\n";
echo"                alert(address + ' not found');\n";
echo"              } else {\n";
echo"                map.setCenter(point, 15);\n";
echo"                var marker = new GMarker(point);\n";
echo"                map.addOverlay(marker); \n";
echo"                map.openInfoWindow(map.getCenter(),document.createTextNode(address));\n";
echo"                map.addControl(mapTypeControl, topRight);\n";
echo"            		GEvent.addListener(map, 'dblclick', function() {\n";
echo"            		 map.removeControl(mapTypeControl);\n";
echo"            		  map.addControl(new GMapTypeControl(), topRight);\n";
echo"            		});\n";
echo"            		GEvent.addListener(map, 'maptypechanged', function() {\n";
echo"            		  if(map.getCurrentMapType().getName()=='Map'){\n";
            			//map view
echo"            			map.setCenter(point, 9);\n";
echo"            			map.closeInfoWindow();\n";
echo"            		  }\n";
echo"            		  else if(map.getCurrentMapType().getName()=='Satellite'){\n";
            			//Satellite view
echo"            			map.setCenter(point, 15);\n";
echo"            			map.closeInfoWindow();\n";
echo"            		  }\n";
echo"            		  else{\n";
            			//hybrid map
echo"            			map.setCenter(point, 15);\n";
echo"            			map.closeInfoWindow();\n";
echo"            		  }\n";
echo"            		});\n";
echo"                map.addControl(new GLargeMapControl());\n";
echo"              	map.addControl(new GOverviewMapControl());\n";
echo"              }\n";
echo"            }\n";
echo"          );\n";
echo"        }\n";
echo"    }\n";
echo"    manageMap();\n";
echo"</script>\n";
?>
